home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / json / tests / test_scanstring.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  4KB  |  55 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. import sys
  5. from json.tests import PyTest, CTest
  6.  
  7. class TestScanstring(object):
  8.     
  9.     def test_scanstring(self):
  10.         scanstring = self.json.decoder.scanstring
  11.         self.assertEqual(scanstring('"z\\ud834\\udd20x"', 1, None, True), (u'z\xf0\x9d\x84\xa0x', 16))
  12.         if sys.maxunicode == 65535:
  13.             self.assertEqual(scanstring(u'"z\xf0\x9d\x84\xa0x"', 1, None, True), (u'z\xf0\x9d\x84\xa0x', 6))
  14.         else:
  15.             self.assertEqual(scanstring(u'"z\xf0\x9d\x84\xa0x"', 1, None, True), (u'z\xf0\x9d\x84\xa0x', 5))
  16.         self.assertEqual(scanstring('"\\u007b"', 1, None, True), (u'{', 8))
  17.         self.assertEqual(scanstring('"A JSON payload should be an object or array, not a string."', 1, None, True), (u'A JSON payload should be an object or array, not a string.', 60))
  18.         self.assertEqual(scanstring('["Unclosed array"', 2, None, True), (u'Unclosed array', 17))
  19.         self.assertEqual(scanstring('["extra comma",]', 2, None, True), (u'extra comma', 14))
  20.         self.assertEqual(scanstring('["double extra comma",,]', 2, None, True), (u'double extra comma', 21))
  21.         self.assertEqual(scanstring('["Comma after the close"],', 2, None, True), (u'Comma after the close', 24))
  22.         self.assertEqual(scanstring('["Extra close"]]', 2, None, True), (u'Extra close', 14))
  23.         self.assertEqual(scanstring('{"Extra comma": true,}', 2, None, True), (u'Extra comma', 14))
  24.         self.assertEqual(scanstring('{"Extra value after close": true} "misplaced quoted value"', 2, None, True), (u'Extra value after close', 26))
  25.         self.assertEqual(scanstring('{"Illegal expression": 1 + 2}', 2, None, True), (u'Illegal expression', 21))
  26.         self.assertEqual(scanstring('{"Illegal invocation": alert()}', 2, None, True), (u'Illegal invocation', 21))
  27.         self.assertEqual(scanstring('{"Numbers cannot have leading zeroes": 013}', 2, None, True), (u'Numbers cannot have leading zeroes', 37))
  28.         self.assertEqual(scanstring('{"Numbers cannot be hex": 0x14}', 2, None, True), (u'Numbers cannot be hex', 24))
  29.         self.assertEqual(scanstring('[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]', 21, None, True), (u'Too deep', 30))
  30.         self.assertEqual(scanstring('{"Missing colon" null}', 2, None, True), (u'Missing colon', 16))
  31.         self.assertEqual(scanstring('{"Double colon":: null}', 2, None, True), (u'Double colon', 15))
  32.         self.assertEqual(scanstring('{"Comma instead of colon", null}', 2, None, True), (u'Comma instead of colon', 25))
  33.         self.assertEqual(scanstring('["Colon instead of comma": false]', 2, None, True), (u'Colon instead of comma', 25))
  34.         self.assertEqual(scanstring('["Bad value", truth]', 2, None, True), (u'Bad value', 12))
  35.  
  36.     
  37.     def test_issue3623(self):
  38.         self.assertRaises(ValueError, self.json.decoder.scanstring, 'xxx', 1, 'xxx')
  39.         self.assertRaises(UnicodeDecodeError, self.json.encoder.encode_basestring_ascii, 'xx\xff')
  40.  
  41.     
  42.     def test_overflow(self):
  43.         with self.assertRaises(OverflowError):
  44.             self.json.decoder.scanstring('xxx', sys.maxsize + 1)
  45.  
  46.  
  47.  
  48. class TestPyScanstring(TestScanstring, PyTest):
  49.     pass
  50.  
  51.  
  52. class TestCScanstring(TestScanstring, CTest):
  53.     pass
  54.  
  55.